package com.atguigu.lease.common.context;

public class LoginUserContext {

    private static ThreadLocal<LoginUser> userThreadLocal = new ThreadLocal<>();

    public static void setLoginUser(Long userId, String username){
        LoginUser loginUser = new LoginUser(userId, username);
        userThreadLocal.set(loginUser);
    }

    public static LoginUser getLoginUser(){
        return userThreadLocal.get();
    }

    public static void clear(){
        userThreadLocal.remove();;
    }




    /*public static void setLoginUser(LoginUser loginUser) {
        userThreadLocal.set(loginUser);
    }

    public static LoginUser getLoginUser() {
        return userThreadLocal.get();
    }

    public static void clear() {
        userThreadLocal.remove();
    }*/
}
